/**
 * SimpleAirportManager.java
 * Dec 29, 2009
 */
package com.dlplay.flightinfo.core;


import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.logging.Logger;

import com.dlplay.flightinfo.data.Airport;
import com.dlplay.flightinfo.data.AirportTerminalCode;
import com.dlplay.flightinfo.source.AirportDataSource;

/**
 * @author zhao yu
 *
 */
public class SimpleAirportManager implements AirportManager {	
	private static final Logger log = Logger.getLogger(SimpleAirportManager.class.getName());
	
	@Override
	public List<Airport> getAirportList() {
		log.info("get airport list");
		return FlightSystem.getFlightInfoDbManager().getAirports();		 
	}

	@Override
	public Airport getAirport(AirportTerminalCode terminal) {
		Airport entry = FlightSystem.getFlightInfoDbManager().getAirport(terminal);
		if(entry!=null)
		{
			log.info("hit in airport db: "+entry);
		}
		else
		{
			log.info("no hit in airport db");
		}
		return entry;		
	}

	@Override
	public void updateAirport(Airport airport) {
		Airport entry = FlightSystem.getFlightInfoDbManager().getAirport(airport.getIdentifier());		
		if(entry==null)
		{
			log.info("add airport: "+airport);
			FlightSystem.getFlightInfoDbManager().addAirport(airport);
		}
		else
		{
			log.info("update airport: "+airport);
			FlightSystem.getFlightInfoDbManager().updateAirport(airport);
		}				
	}

}
